// Copyright (C) 2008 Taylor L. Riche <riche@cs.utexas.edu>
//  
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software 
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//

/**
 * 
 */
package profcomp.entities;

import java.util.Map;

/**
 * @author riche
 *
 */
public class OperatorInfo {

	private final String name;
	private final Map<String, PortInfo> portMap;
	
	/**
	 * @param name
	 * @param portList
	 */
	private OperatorInfo(final String name, final Map<String, PortInfo> portMap) {
		this.name = name;
		this.portMap = portMap;
	}
	
	public static OperatorInfo create(String n, Map<String, PortInfo> pm) {
		return new OperatorInfo(n, pm);
	}

	/**
	 * 
	 * @param portname Name of the port to lookup profiling information
	 * @return The PortInfo object
	 */
	public PortInfo lookupPort(String portname) {
		return portMap.get(portname);
	}

	/**
	 * @return the name of the associated Operator
	 */
	public String getName() {
		return name;
	}
	
	public void printPorts() {
		for (PortInfo port : portMap.values()) {
			System.out.println("\t" + port.getName() + ":" + port.getValue());
		}
	}
	
}
